home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
By Popular Request 2.0
/
By Popular Request 2.0 (Arsenal Computer).ISO
/
amiga_4
/
mkicnsfx.lha
/
MakeIcons_ifx
/
MakeIcons.ifx
< prev
next >
Wrap
Text File
|
1995-03-19
|
3KB
|
149 lines
/*
* Arexx Macro for creating icons from images
* Created by Per Espen Hagen
* $VER: MakeIcons 2.1 (13.2.1995)
*
*/
OPTIONS RESULTS
/****** Get user input ******/
Files = ""
RollScreenUp 400
ADDRESS command 'RxSet Files `RequestFile MultiSelect Title="Select picture file(s)"`'
RollScreenDown
Files = GetClip('Files')
Files = Compress(Files, '"')
IF Files = "" THEN DO
RequestNotify "No files selected."
Exit
END
/* Options requester */
Gad.1 = 'J/80/17/25/Contrast:/20'
Gad.2 = 'J/80/32/25/Gamma:/32'
Gad.3 = 'J/80/47/25/Sharpen:/5'
Gad.4 = 'J/180/17/25/Max Size:/80'
Gad.5 = 'J/228/17/25/x/60'
Gad.6 = 'J/180/32/25/Step Size:/4'
Gad.7 = 'J/228/32/25/x/4'
Gad.8 = 'J/180/47/25/Bitplanes:/3'
Gad.9 = 'X/275/18/Use Aspect?/0'
Gad.10= 'X/275/33/Grayscale?/0'
Gad.11= 'X/275/48/HAM?/0'
ComplexRequest '"MakeIcons"' 11 Gad 390 83
Con = Result.1
Gam = Result.2
Sharp = Result.3
MaxW = Result.4
MaxH = Result.5
StepX = Result.6
StepY = Result.7
Planes = Result.8
UseAsp = Result.9
Gray = Result.10
HAM = Result.11
/****** Convert & check input validity ******/
SELECT
WHEN Planes = 1 THEN NCol = 2
WHEN Planes = 2 THEN NCol = 4
WHEN Planes = 3 THEN NCol = 8
WHEN Planes = 4 THEN NCol = 16
WHEN Planes = 5 THEN NCol = 32
WHEN Planes = 6 THEN NCol = 64
WHEN Planes = 7 THEN NCol = 128
WHEN Planes = 8 THEN NCol = 256
OTHERWISE
RequestNotify "Planes must be in the range 1-8"
Exit
END
/****** Initialize ImageFX ******/
/* Disable Undo, if enabled */
GetPrefs Undo
PrefUndo = Result
SetPrefs Undo OFF
/* Set a few render options */
Palette 8
LockRange 0 OFF
LoadPalette "ImageFX:Storage/Palettes/Workbench" '-1'
LockRange 0 ON
Render Dither 1 0 0
Render ModeID 2048 * HAM /* Default mode, '0', for non-HAM */
Render Colors NCol
/****** Main Loop ******/
NFiles = Words(Files)
DO FrameNo = 1 TO NFiles
PARSE Var Files File Files
/* Load a picture */
LoadBuffer File Force NOSMOOTH
GetMain
IF Result = "" THEN DO
RequestNotify "Unable to load file. Out of memory?"
END
ELSE DO
Data = Result
PARSE VAR Data Name W H Depth AspX AspY Dummy
SAY "Filename = "||Name
/* Possible aspect adjustment */
IF UseAsp THEN DO
W = W * AspX
H = H * AspY
END
IF (W*MaxH) > (H*MaxW) THEN DO
IconW = MaxW
IconH = ((H*IconW/W + StepY - 1) % StepY) * StepY
END
ELSE DO
IconH = MaxH
IconW = ((W*IconH/H + StepX - 1) % StepX) * StepX
END
Scale IconW IconH
/* Convert to B/W, if desired */
IF Depth = 3 & Gray THEN
ColorToGray Luma
/* Convert to colour, if necessary */
IF Depth = 1 | Gray THEN
GrayToColor
/* Contrast enhancement */
Contrast Con
Gamma Gam
UnsharpMask Sharp
/* Render the icon and save it */
Render Go
SaveRenderedAs Icon File FORCE
Render Close
/* Add default tool to icon */
ADDRESS command 'NewTool' File
END
END
/* Reset Undo to previous state */
SetPrefs Undo PrefUndo